package com.cloud.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.cloud.domian.Result;
import com.cloud.domian.Stock;
import com.cloud.exception.MyBlockExceptionHandler;
import com.cloud.service.IStockService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author wenbo
 * @Date 2022/12/13 11:02
 **/
@RestController
@RequestMapping("/item")
public class ItemController {

    @Value("${server.port}")
    private String port;



    /**
     * 获取商品的信息
     *
     * @param id
     * @return
     */
    //@SentinelResource(value = "/doOrder",blockHandlerClass = MyBlockExceptionHandler.class)
    @GetMapping("/doOrder")
    public String doOrder(){
        String itemInfo = "订单生成:"+port;
        return itemInfo;
    }

    /**
     * 获取商品的信息
     *
     * @param id
     * @return
     */
    @GetMapping("/item/{id}")
    //@SentinelResource(value = "/item")
    public String getInfo(@PathVariable(name = "id") String id) {
        System.out.println("id:"+id);
        String itemInfo = "订单信息:"+port;
        return itemInfo;
    }


}
